package com.stegniy.queue;

import java.util.NoSuchElementException;

public class ArrayQueue<E> implements Queue<E> {

    private static final int DEFAULT_CAPACITY = 10;

    private int capacity;
    private Object[] array;
    private int size;
    private int tail;
    private int head;

    public ArrayQueue() {
        array = new Object[DEFAULT_CAPACITY];
    }

    public ArrayQueue(int capacity) {
        array = new Object[capacity];
    }

    /*Retrieves, but does not remove, the head of this queue*/
    public E element() {
        if (size > 0) {
            return (E) array[head];
        } else {
            throw new NoSuchElementException();
        }
    }

    /*Inserts the specified element into this queue if it is possible to do
      so immediately without violating capacity restrictions*/
    public boolean offer (E e) {
        if (size < capacity) {
            array[size++] = e;
            return true;
        } else {
            return false;
        }
    }

    /*Retrieves, but does not remove, the head of this queue,
      or returns null if this queue is empty*/
    public E peek() {
        if (size > 0) {
            return (E) array[head];
        } else {
            return null;
        }
    }

    /*Retrieves and removes the head of this queue,
      or returns null if this queue is empty*/
    public E poll() {

    }

    /*Retrieves and removes the head of this queue*/
    public E remove() {}
}
